/**
 * 
 */
package com.haizhi.util;

import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import com.haizhi.util.MyMapBuilder.ErrorCode;

/**
 * @author jiangjintai
 *
 */
public class ResponseEntityUtil {
	public static ResponseEntity<Map<String,Object>>  buildErrorEntity(ErrorCode errorCode,String message){
		MyMap map = MyMapBuilder.buildErrorMap(errorCode, message);
		ResponseEntity<Map<String,Object>> entity=null;
		switch (errorCode) {
		case paramError:
			entity = new ResponseEntity<Map<String, Object>>(map,HttpStatus.BAD_REQUEST);
			break;
		case phoneUsedError:
		case noLoginError:
		case nameUsedError:
		case loginFailError:
			entity = new ResponseEntity<Map<String, Object>>(map,HttpStatus.UNAUTHORIZED);
			break;
		case noAuthorityError:
			entity = new ResponseEntity<Map<String, Object>>(map,HttpStatus.FORBIDDEN);
			break;
		case noUserError:
			entity = new ResponseEntity<Map<String, Object>>(map,HttpStatus.NOT_FOUND);
			break;

		default:
			break;
		}
		return entity;
	}
}
